import numpy as np
import torch
import random
import math
import torch.nn.functional as F
import matplotlib.pyplot as plt
import re
import torch.nn as nn
import copy
import warnings
import copy
from pathlib import Path
import seaborn as sn

array = np.arange(8*8).reshape(8, 8)
fig = plt.figure(figsize=(12, 9), tight_layout=True)
names = ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck']
with warnings.catch_warnings():
    warnings.simplefilter('ignore')  # suppress empty matrix RuntimeWarning: All-NaN slice encountered
    # sn和fig是咋关联起来的？
    sn.heatmap(array,  annot_kws={"size": 8}, cmap='Blues', fmt='.2f', square=True,
               xticklabels=names,
               yticklabels=names).set_facecolor((1, 1, 1))
fig.axes[0].set_xlabel('True')
fig.axes[0].set_ylabel('Predicted')
fig.savefig('confusion_matrix.png', dpi=250)
plt.close()  # 证明确实关联起来了
